package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import com.atguigu.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Tu
 * @date 2023/5/1 15:23
 */
@Slf4j
@RestController
public class OrderFeignController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    /**
     * 通过id查询支付信息
     *
     * @param id
     * @return
     */
    @GetMapping("/consumer/payment/selById/{id}")
    public CommonResult selPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.selPaymentById(id);
    }

    /**
     * 新增支付信息
     *
     * @param payment
     * @return
     */
    @PostMapping(value = "/consumer/payment/insert")
    public CommonResult insertPayment(@RequestBody Payment payment) {
        return paymentFeignService.insertPayment(payment);
    }

    /**
     * 模拟feignClient调用超时
     *
     * @return
     */
    @GetMapping(value = "/api/v1/payment/timeout")
    String paymentFeignTimeout() {
        return paymentFeignService.paymentFeignTimeout();
    }

}
